﻿using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace NTQOnlineExam.Services.Infrastructure.Utility
{
    public static class PhoneNumberUtilities
    {
        private const string PHONE_NUMBER_REGEX = @"^\({0,1}((0|\+61)(2|4|3|7|8)){0,1}\){0,1}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{1}(\ |-){0,1}[0-9]{3}$";

        public static bool ValidatePhoneNumber(string phoneNumber)
        {
            if (string.IsNullOrEmpty(phoneNumber)) return false;

            Regex remove = new Regex("[^0123456789\\+]");
            Regex regex = new Regex(PHONE_NUMBER_REGEX, RegexOptions.IgnorePatternWhitespace);
            return regex.IsMatch(remove.Replace(phoneNumber, string.Empty));
        }
        
    }
}
